package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.nursing.domain.NursingProject;
import com.zzyl.nursing.service.INursingProjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 会员端护理项目Controller
 */
@RestController
@RequestMapping("/member/orders/project")
@Api(tags = "会员端护理项目接口")
public class MemberNursingProjectController extends BaseController {
    
    @Autowired
    private INursingProjectService nursingProjectService;
    
    /**
     * 分页查询护理项目列表
     */
    @ApiOperation("分页查询护理项目列表")
    @GetMapping("/page")
    public TableDataInfo page(
            @RequestParam(value = "name", required = false) String name,
            @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
            @RequestParam(value = "status", required = false) Integer status) {
        
        // 创建查询条件
        NursingProject nursingProject = new NursingProject();
        nursingProject.setName(name);
        nursingProject.setStatus(status);
        
        // 设置分页参数
        startPage();
        
        // 查询数据
        List<NursingProject> list = nursingProjectService.selectNursingProjectList(nursingProject);
        
        // 直接返回TableDataInfo对象
        return getDataTable(list);
    }
    
    /**
     * 根据编号查询护理项目信息
     */
    @ApiOperation("根据编号查询护理项目信息")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        NursingProject nursingProject = nursingProjectService.selectNursingProjectById(id);
        return success(nursingProject);
    }
} 